package com.example.miaosha.controller;

import com.example.miaosha.entity.base.BaseResponse;
import com.example.miaosha.service.OrderService;
import com.example.miaosha.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 订单管理
 *
 * @Author
 * @Date 2022/1/18 11:07
 */
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/order")
@Api("秒杀订单管理")
public class OrderController {
    @Resource
    private OrderService orderService;

    /**
     * 取消订单(秒杀活动中的订单)
     *
     * @param orderNo
     * @return
     */
    public BaseResponse cancelOrder(String orderNo) {
        return BaseResponse.success(orderService.cancelSeckillOrder(orderNo));
    }

    /**
     * 添加订单
     *
     * @return
     */
    public BaseResponse addOrder() {
        return null;
    }

    /**
     * 更新
     *
     * @return
     */
    public BaseResponse updateOrder() {
        return null;
    }

    /**
     * 分页查询订单
     *
     * @return
     */
    @ApiOperation("查看订单")
    @PostMapping("/list")
    public BaseResponse selectOrder(@RequestBody OrderVo vo) {
        return orderService.selectOrder(vo);
    }

    /**
     * 查看订单详情
     */
    public BaseResponse findOrder() {
        return null;
    }


    /**
     * 管理员查看活动汇总
     *
     * @return
     */
    @ApiOperation("查看活动汇总")
    @PostMapping("/selectByActId")
    public BaseResponse selectByActId(@RequestBody OrderVo vo) {
        return orderService.selectByActId(vo);
    }


}
